package cn.kgc.maoqichao.microservicecloudconsumerdept80.controller;

import cn.kgc.maoqichao.microservicecloudconsumerdept80.service.CategoryClientService;
import cn.kgc.maoqichao.microservicecloudproviderdept8001.pojo.Category;
import cn.kgc.maoqichao.microservicecloudproviderdept8001.pojo.ResultEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;
import java.util.Locale;

@RestController
@RequestMapping("/consumer/category")
public class CategoryController {
    @Resource
    CategoryClientService categoryClientService;

    @RequestMapping("/list")
    public ResultEntity<List<Category>> list(){
        return categoryClientService.list();
    }

    @RequestMapping("/get/{id}")
    public ResultEntity<Category> get(@PathVariable(value = "id") Integer id){
        return categoryClientService.get(id);
    }

    @RequestMapping("/update")
    public ResultEntity<String> update(@RequestBody Category category){
        return categoryClientService.update(category);
    }

    @RequestMapping("/insert")
    public ResultEntity<String> insert(@RequestBody Category category){
        return categoryClientService.insert(category);
    }

    @RequestMapping("/delete/{id}")
    public ResultEntity<String> delete(@PathVariable(value = "id") Integer id){
        return categoryClientService.delete(id);
    }

}
